home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / fsovl / zip / unzip / y.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-24  |  4.8 KB  |  140 lines

  1.  
  2.  
  3. #include "unzip.h"               /* includes, defines, and macros */
  4. #ifdef MSWIN
  5. #  include "wizunzip.h"          /* see History.500 for version history */
  6. #endif
  7.  
  8. #define VERSION  "v5.0 of 21 August 1992"
  9. /* #define VERSION  "v5.0p BETA of 8-21-92" */   /* internal beta level */
  10. #define PAKFIX   /* temporary(?) solution to PAK-created zipfiles */
  11.  
  12. char *SeekMsg = "AA";
  13. char *ReportMsg = "BB";
  14.  
  15.  
  16. /**********************/
  17. /*  Global Variables  */
  18. /**********************/
  19.  
  20. int aflag=0;          /* -a: do ASCII to EBCDIC translation, or CR-LF  */
  21.                       /*     to CR or LF conversion of extracted files */
  22. /* int bflag=0; RESERVED for -b: extract as binary */
  23. int cflag=0;          /* -c: output to stdout */
  24. int fflag=0;          /* -f: "freshen" (extract only newer files) */
  25. int jflag=0;          /* -j: junk pathnames */
  26. int overwrite_none=0; /* -n: never overwrite files (no prompting) */
  27. int overwrite_all=0;  /* -o: OK to overwrite files without prompting */
  28. int force_flag=0;     /* (shares -o for now): force to override errors, etc. */
  29. int quietflg=0;       /* -q: produce a lot less output */
  30. #ifdef DOS_OS2
  31.    int sflag=1;       /* -s: allow spaces (blanks) in filenames */
  32. #endif /* DOS_OS2 */
  33. int tflag=0;          /* -t: test */
  34. int uflag=0;          /* -u: "update" (extract only newer & brand-new files) */
  35. static int U_flag=0;  /* -U: leave filenames in upper or mixed case */
  36. static int vflag=0;   /* -v: view directory (only used in unzip.c) */
  37. int V_flag=0;         /* -V: don't strip VMS version numbers */
  38. #ifdef VMS
  39.    int secinf=0;      /* -X: keep owner/protection */
  40. #endif /* VMS */
  41. int zflag=0;          /* -z: display only the archive comment */
  42. int process_all_files=0;
  43.  
  44. longint csize;        /* used by list_files(), ReadByte(): must be signed */
  45. longint ucsize;       /* used by list_files(), unReduce(), explode() */
  46.  
  47. char *fnames[2] = {"*", NULL};   /* default filenames vector */
  48. char **fnv = fnames;
  49. char sig[5];
  50. char answerbuf[10];
  51.  
  52. min_info info[DIR_BLKSIZ], *pInfo=info;
  53.  
  54. #ifdef OS2
  55.    int longname;              /* used in extract.c, mapname.c and file_io.c */
  56.    char longfilename[FILNAMSIZ];
  57. #endif /* OS2 */
  58.  
  59. #ifdef CRYPT
  60.    char *key = (char *)NULL;  /* password with which to decrypt data, or NULL */
  61. #endif /* CRYPT */
  62.  
  63. /*---------------------------------------------------------------------------
  64.     unShrink/unReduce/explode/inflate working storage and globals:
  65.   ---------------------------------------------------------------------------*/
  66.  
  67. #ifdef NOTDEF
  68. __far union work area;              /* see unzip.h for the definition of work */
  69. #endif
  70. ULONG crc32val;
  71.  
  72. UWORD mask_bits[] = {
  73.     0x0000,
  74.     0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
  75.     0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
  76. };
  77.  
  78. /*---------------------------------------------------------------------------
  79.     Input file variables:
  80.   ---------------------------------------------------------------------------*/
  81.  
  82. byte *inbuf, *inptr;     /* input buffer (any size is legal) and pointer */
  83. int incnt;
  84.  
  85. ULONG bitbuf;
  86. int bits_left;
  87. boolean zipeof;
  88.  
  89. int zipfd;               /* zipfile file handle */
  90. #ifdef MSWIN
  91.    char *zipfn;
  92. #else
  93.    char zipfn[FILNAMSIZ];
  94. #endif
  95.  
  96. char local_hdr_sig[5] = "\120";    /* remaining signature bytes come later   */
  97. char central_hdr_sig[5] = "\120";  /*  (must initialize at runtime so unzip  */
  98. char end_central_sig[5] = "\120";  /*  executable won't look like a zipfile) */
  99. /* char extd_local_sig[5] = "\120";  NOT USED YET */
  100.  
  101. cdir_file_hdr crec;      /* used in unzip.c, extract.c, misc.c */
  102. local_file_hdr lrec;     /* used in unzip.c, extract.c */
  103. ecdir_rec ecrec;         /* used in unzip.c, extract.c */
  104. struct stat statbuf;     /* used by main(), mapped_name(), check_for_newer() */
  105.  
  106. longint extra_bytes = 0;        /* used in unzip.c, misc.c */
  107. longint cur_zipfile_bufstart;   /* extract_or_test_files, readbuf, ReadByte */
  108.   
  109. #ifdef MACOS
  110.    short  gnVRefNum;
  111.    long  glDirID;
  112.    OSType  gostCreator;
  113.    OSType  gostType;
  114.    boolean  fMacZipped;
  115.    boolean  macflag;
  116.    CursHandle  rghCursor[4];    /* status cursors */
  117.    short  giCursor = 0;
  118. #endif
  119.  
  120. /*---------------------------------------------------------------------------
  121.     Output stream variables:
  122.   ---------------------------------------------------------------------------*/
  123.  
  124. byte *outbuf;                   /* buffer for rle look-back */
  125. byte *outptr;
  126. #ifdef MSWIN
  127.    byte __far *outout;
  128.    char *filename;
  129. #else /* !MSWIN */
  130.    byte *outout;                /* scratch pad for ASCII-native trans */
  131.    char filename[FILNAMSIZ];
  132. #endif /* ?MSWIN */
  133. byte *extra_field = (byte *)NULL;  /* used by VMS, Mac and OS/2 versions */
  134. longint outpos;                 /* absolute position in outfile */
  135. int outcnt;                     /* current position in outbuf */
  136. int outfd;
  137. int mem_mode = 0;
  138. int disk_full;
  139.  
  140.